home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 7421 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.4 KB  |  36 lines

  1. Newsgroups: comp.lang.c
  2. Path: network.com!news
  3. From: collim@anubis.network.com (Mike Collins)
  4. Subject: Processing a structure- how?
  5. X-Nntp-Posting-Host: collim.network.com
  6. Message-ID: <DnDv98.Ko1@network.com>
  7. Sender: news@network.com
  8. Organization: Network Systems Corporation
  9. X-Newsreader: WinVN 0.93.11
  10. Mime-Version: 1.0
  11. Date: Mon, 26 Feb 1996 12:41:31 GMT
  12.  
  13. Folks,
  14.  
  15. I want to write a generic routine that will print data contained 
  16. in structures on the screen (of a DOS-based PC, but I don't think that 
  17. comes into it). What I want is to be able to pass a structure  or 
  18. structure pointer to the routine, which will then be able to find out what 
  19. the contents of the structure are, so that if I pass a customer structure 
  20. containing surname, forename, address, phone number, I will be able to 
  21. print this. If I pass a different structure containing catalog data, I 
  22. will be able to print Item, category, bin location, etc.
  23.  
  24. Is there a way for a function to find out how many fields are in a 
  25. structure and what kind of variable each is (int, char[], etc)? I reallise 
  26. that this information is known to the compiler and not to the compiled 
  27. program as such, but can the compiler be made to embed information of this 
  28. kind into a program?
  29.  
  30. The effect would be like a printf() statement (I don't mind sending it a 
  31. formatting string), but with only a structure or structure pointer as a 
  32. data argument.
  33.  
  34. Mike.
  35.  
  36.